package cn.xo68.metadata.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import cn.xo68.boot.web.common.ResponseResultConstants;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageInfo;
import cn.xo68.metadata.entity.MetadataColumn;
import cn.xo68.metadata.service.MetadataColumnService;



/** 
 * MetadataColumn controller
 * @author wuyy(16349023@qq.com)
 * @date 2020年03月12日 11:44:16
 *
 */
 @Api(value = "MetadataColumn",tags = {"MetadataColumn"})
@RequestMapping("/MetadataColumn")
@Slf4j
@RestController
public class MetadataColumnController{

    @Autowired
    private MetadataColumnService metadataColumnService;

    @ApiOperation(value="详情")
	@GetMapping("/detail/{columnId}")
    public MetadataColumn detail(@PathVariable(name="columnId") Integer columnId) {
        return metadataColumnService.find(columnId);
    }
    
    @ApiOperation(value="翻页列表")
    @GetMapping("/list")
    public PageInfo<MetadataColumn> list(@RequestParam(name="pageIndex",defaultValue="1") int pageIndex,@RequestParam(name="pageSize",defaultValue="10") int pageSize){
        return metadataColumnService.list(pageIndex, pageSize);
    }
	
    @ApiOperation(value="创建")
	@PostMapping
    public MetadataColumn add(@RequestBody MetadataColumn entity ) {
        return metadataColumnService.insert(entity);
    }
	
    @ApiOperation(value="删除")
	@DeleteMapping
	public String delete(@RequestParam(name="id") Integer id) {
	    metadataColumnService.delete(id);
        return ResponseResultConstants.RESPONSE_DATA_SUCCESS;
	}
	
    @ApiOperation(value="更新")
	@PutMapping
	public MetadataColumn update(@RequestBody MetadataColumn entity) {
	    return metadataColumnService.update(entity);
	}
}